package com.dong.controller;

import com.dong.pojo.Iidar;
import com.dong.service.QueryIidarServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Base64;
/*
激光雷达界面
 */


@Controller
public class IntegratedSystemController {
    @Autowired
    QueryIidarServiceImpl queryIidarService;

    //激光雷达界面
    @RequestMapping("/system")
    public String system(Model model){
        System.out.println("进激光雷达界面");
        Iidar queryIidar = queryIidarService.queryIidar();
        byte[] weather_pictures = queryIidar.getWeather_pictures();
        byte[] echosignal_pictures = queryIidar.getEchosignal_pictures();
        //取出二进制图片进行Base64编码用于前端显示
        String weatherPictures_Base64 = Base64.getEncoder().encodeToString(weather_pictures);
        String echosignalPictures_Base64 = Base64.getEncoder().encodeToString(echosignal_pictures);
        model.addAttribute("lidar",queryIidar);
        model.addAttribute("weatherPictures",weatherPictures_Base64);
        model.addAttribute("echosignalPictures",echosignalPictures_Base64);
        return "IntegratedSystem/system";
    }


    //方舱天窗界面
    @RequestMapping("/sunroof")
    public String sunroof(Model model){
        System.out.println("进入方舱天窗界面");
        return "IntegratedSystem/sunroof";
    }

    //天气系统界面
    @RequestMapping("/weather")
    public String weather(Model model){
        System.out.println("进入天气系统界面");
        return "IntegratedSystem/weather";
    }

    //pmt界面
    @RequestMapping("/pmt")
    public String pmt(Model model){
        System.out.println("进入pmt界面");
        return "IntegratedSystem/pmt";
    }
    //数据采集界面
    @RequestMapping("/data")
    public String data(Model model){
        System.out.println("进入数据采集界面");
        return "IntegratedSystem/data";
    }

    //收发匹配界面
    @RequestMapping("/motor")
    public String motor(Model model){
        System.out.println("进入收发匹配界面");
        return "IntegratedSystem/motor";
    }

    //望远镜界面
    @RequestMapping("/telescope")
    public String sunRoof(Model model){
        System.out.println("进入望远镜界面");
        return "IntegratedSystem/telescope";
    }

}
